# -*- encoding=utf8 -*-
"""
RedFlag-TC000010   相册滑动
进入相册后进行滑动查看手机相册
"""
__author__ = "ldm"

import sys
import os
# 获取当前脚本所在目录.py
current_dir = os.path.dirname(os.path.abspath(__file__))
# 获取上级目录.air
parent_dir = os.path.dirname(current_dir)
# 获取上级目录air
grandparent_dir = os.path.dirname(parent_dir)
# 获取和air目录平级的conf、testcase目录路径
conf_dir = os.path.join(grandparent_dir, 'conf')
testcase_dir = os.path.join(grandparent_dir, 'testcase')
# 将conf、testcase目录添加到sys.path
sys.path.append(conf_dir)
sys.path.append(testcase_dir)

from PageFunction import CameraVideoShooter
from elements import *
auto_setup(__file__)

shooter = CameraVideoShooter()
log("-----------------------------------------------------------------滑动相册------------------------------------------------------------------------------")
# 进入相册
shooter.enter_album()
# 点击照片
shooter.click_element(album_photo_list)
# 进行滑动操作
shooter.swipe_screen((0.5, 0.8), (0.5, 0.2), 0.5, 20)
# 选择一个素材
shooter.click_element(album_select_button[6])
# 点击下一步进入装饰页
shooter.click_element(album_next_button)
# 等待发布按钮
shooter.wait_for_element_appearance(decoration_page_release_video, 60)
# 点击返回返回相册页
shooter.click_element(decoration_page_return_button)
# 点击删除刚才选择的素材
shooter.click_element(material_deletion_delete_button)
# 断言，判断是否删除了素材，成功则表示页面正常无崩溃
shooter.assert_element_not_exists(preview_bar_elow, "用例执行失败，检测到预览栏")
#关闭应用
stop_app(UGC_package_name)